package com.top10.controller;

import com.top10.bean.ResponseBean;
import com.top10.entity.Stock;
import com.top10.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 库存Controller
 * @author ellen
 * @version 1.0
 * @date 2018/9/29 21:18
 */
@RestController
@RequestMapping("/manager/stock")
public class StockController {

    @Autowired
    IStockService stockService;

    /**
     * 查询商品库存
     * @return
     */
    @RequestMapping("/getStock")
    public ResponseBean getStock(Integer id){
        if(id == null){
            return ResponseBean.createError("商品id不能为空");
        }
        List<Stock> stocks = stockService.getStock(id);

        return ResponseBean.createSuccess().addData("stocks", stocks);
    }
}
